package com.eascs.o2o.loan.service.impl;

import java.util.Date;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.eascs.app.dao.JdbcSession;
import com.eascs.o2o.loan.entity.LoanWeChatEntity;
import com.eascs.o2o.loan.service.LoanService;

@Service("loanServiceImpl")
public class LoanServiceImpl implements LoanService{

	@Autowired
	@Qualifier("wxSession")
	protected JdbcSession jdbcSession;
	
	@Override
	public int saveLoanWeChat(LoanWeChatEntity loanWeChat) {
		loanWeChat.setCreateTime(new Date());
		return jdbcSession.insert(loanWeChat);
	}

	@Override
	public int updateLoanWeChat(LoanWeChatEntity loanWeChat) {
		if (StringUtils.isBlank(loanWeChat.getId())) {
			return 0;
		}
		return jdbcSession.updateById(loanWeChat);
	}

	@Override
	public LoanWeChatEntity queryLoanWeChatById(String id) {
		String sql="select * from loan_wechat where id=?";
		return jdbcSession.findEntity(sql, LoanWeChatEntity.class, id);
	}

	@Override
	public LoanWeChatEntity queryLoanWeChatByOpenId(String openId) {
		String sql="select * from loan_wechat where openid=?";
		return jdbcSession.findEntity(sql, LoanWeChatEntity.class, openId);
	}


}
